package com.cbs.zxing.test;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.ImageView;
import cn.bingoogolapple.qrcode.zxing.QRCodeEncoder;
import com.cbs.ui.qrcodegen.QRCodeGenerator;

/**
 * Created by broche on 6/22/16.
 */
public class GenActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gen);

        final ImageView imageView1 = (ImageView) findViewById(R.id.image1);
        final ImageView imageView2 = (ImageView) findViewById(R.id.image2);
        final ImageView imageView3 = (ImageView) findViewById(R.id.image3);
        ImageView imageView4 = (ImageView) findViewById(R.id.image4);
        ImageView imageView5 = (ImageView) findViewById(R.id.image5);
        ImageView imageView6 = (ImageView) findViewById(R.id.image6);

        QRCodeGenerator.encodeQRCode("test123", 10, new QRCodeEncoder.Delegate() {
            @Override
            public void onEncodeQRCodeSuccess(Bitmap bitmap) {
                imageView1.setImageBitmap(bitmap);
            }

            @Override
            public void onEncodeQRCodeFailure() {

            }
        });
        QRCodeGenerator.encodeQRCode("test123", 20, Color.RED, new QRCodeEncoder.Delegate() {
            @Override
            public void onEncodeQRCodeSuccess(Bitmap bitmap) {
                imageView2.setImageBitmap(bitmap);
            }

            @Override
            public void onEncodeQRCodeFailure() {

            }
        });
        QRCodeGenerator.encodeQRCode("test123", 30, Color.BLUE, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher), new QRCodeEncoder.Delegate() {
            @Override
            public void onEncodeQRCodeSuccess(Bitmap bitmap) {
                imageView3.setImageBitmap(bitmap);
            }

            @Override
            public void onEncodeQRCodeFailure() {

            }
        });

        QRCodeGenerator.fillQRCode("test123", imageView4);
        QRCodeGenerator.fillQRCode("test123", Color.GREEN, imageView5);
        QRCodeGenerator.fillQRCode("test123", Color.CYAN, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher), imageView6);
    }
}
